package com.probox.modules.controller.platfom;

import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.log.annotation.Log;
import com.probox.common.log.enums.BusinessType;
import com.probox.common.security.annotation.PreAuthorize;
import com.probox.common.entity.domain.platfom.PlatformTemplateUrl;
import com.probox.common.entity.domain.platfom.vo.OptionsSelect;
import com.probox.common.entity.service.platfom.IPlatformTemplateUrlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 平台_模板链接配置Controller
 *
 *
 * @date 2021-06-15
 */
@Api(value = "平台模块", tags = {"模板链接接口"})
@RestController
@RequestMapping("/platform/templateurl")
public class PlatformTemplateUrlController extends BaseController {
    @Autowired
    private IPlatformTemplateUrlService platformTemplateUrlService;

    /**
     * 查询平台_模板链接配置列表
     */
    @PreAuthorize(hasPermi = "platform:templateurl:list")
    @GetMapping("/list")
    public AjaxResult list(PlatformTemplateUrl platformTemplateUrl) {
        List<PlatformTemplateUrl> list = platformTemplateUrlService.queryList(platformTemplateUrl);
        return AjaxResult.success(list);
    }

    /**
     * 获取平台_模板链接配置详细信息
     */
    @PreAuthorize(hasPermi = "platform:templateurl:query")
    @GetMapping(value = "/{urlUid}")
    public AjaxResult getInfo(@PathVariable("urlUid") Long urlUid) {
        return AjaxResult.success(platformTemplateUrlService.selectPlatformTemplateUrlById(urlUid));
    }

    /**
     * 新增平台_模板链接配置
     */
    @PreAuthorize(hasPermi = "platform:templateurl:add")
    @Log(title = "平台_模板链接配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformTemplateUrl platformTemplateUrl) {
        return toAjax(platformTemplateUrlService.insertPlatformTemplateUrl(platformTemplateUrl));
    }

    /**
     * 修改平台_模板链接配置
     */
    @PreAuthorize(hasPermi = "platform:templateurl:edit")
    @Log(title = "平台_模板链接配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformTemplateUrl platformTemplateUrl) {
        return toAjax(platformTemplateUrlService.updatePlatformTemplateUrl(platformTemplateUrl));
    }

    /**
     * 删除平台_模板链接配置
     */
    @PreAuthorize(hasPermi = "platform:templateurl:remove")
    @Log(title = "平台_模板链接配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{urlUids}")
    public AjaxResult remove(@PathVariable Long[] urlUids) {
        return toAjax(platformTemplateUrlService.deletePlatformTemplateUrlByIds(urlUids));
    }

    /**
     *  获模板链接的级联列表
     * @return
     */
    @GetMapping("/urlSelect")
    @ApiOperation(value = " 获模板链接的级联列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = OptionsSelect.class),
    })
    public AjaxResult bulidSelect(){
        return AjaxResult.success(platformTemplateUrlService.selectOptionList());
    }

}
